using System;
using System.Collections.Generic;
using System.Text;
using Entities;
using DAL;
namespace BUS
{
   public  class tbSanPhamBUS
    {
        public static void Insert(tbSanPham sanpham)
        {
            tbSanPhamDAL sanphamDAL = new tbSanPhamDAL();
            sanphamDAL.Insert(sanpham);

        }
        public static void Uptate(tbSanPham sanpham)
        {
            tbSanPhamDAL sanphamDAL = new tbSanPhamDAL();
            sanphamDAL.Update(sanpham);

        }
        public static void Delete(int iD)
        {
            tbSanPhamDAL sanphamDAL = new tbSanPhamDAL();
            sanphamDAL.Delete(iD);
        }
        public static tbSanPhamCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbSanPhamDAL sanphamDAL = new tbSanPhamDAL();
            return sanphamDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbSanPhamCollection GetAll()
        {
            int total = 0;
            tbSanPhamDAL sanphamDAL = new tbSanPhamDAL();
            return sanphamDAL.Get("where 1=1", 0, 0,
            tbSanPhamColumns.MaSP .ToString(),
            "ASC", out total);
        }
        public static tbSanPham GetByID(int iD)
        {
            int total = 0;
            tbSanPhamDAL sanphamDAL = new tbSanPhamDAL();
            tbSanPhamCollection sanphamCollection = sanphamDAL.Get("where " +
            tbSanPhamColumns.MaSP .ToString() + "=" + iD.ToString(),
            0, 0, tbSanPhamColumns.MaSP .ToString(), "ASC", out total);
            if (sanphamCollection.Count > 0)
                return sanphamCollection[0];
            return null;
        }

    }
}
